.class final Lnbisdk/dg$b;
.super Lnbisdk/lp;


# annotations
.annotation system Ldalvik/annotation/EnclosingClass;
    value = Lnbisdk/dg;
.end annotation

.annotation system Ldalvik/annotation/InnerClass;
    accessFlags = 0x0
    name = "b"
.end annotation


# instance fields
.field private synthetic fb:Lnbisdk/dg;


# direct methods
.method constructor <init>(Lnbisdk/dg;)V
    .locals 1

    iput-object p1, p0, Lnbisdk/dg$b;->fb:Lnbisdk/dg;

    const-string v0, "Output Thread"

    invoke-direct {p0, v0}, Lnbisdk/lp;-><init>(Ljava/lang/String;)V

    return-void
.end method

.method private a(Ljava/io/OutputStream;)V
    .locals 4

    const/4 v0, 0x1

    :cond_0
    :goto_0
    :try_start_0
    iget-object v1, p0, Lnbisdk/dg$b;->fb:Lnbisdk/dg;

    invoke-static {v1}, Lnbisdk/dg;->b(Lnbisdk/dg;)Ljava/io/ByteArrayOutputStream;

    move-result-object v1

    monitor-enter v1
    :try_end_0
    .catchall {:try_start_0 .. :try_end_0} :catchall_0

    if-eqz v0, :cond_1

    const/4 v0, 0x0

    :goto_1
    :try_start_1
    iget-object v2, p0, Lnbisdk/dg$b;->fb:Lnbisdk/dg;

    invoke-virtual {v2}, Lnbisdk/dg;->isOpen()Z

    move-result v2

    if-nez v2, :cond_2

    monitor-exit v1
    :try_end_1
    .catchall {:try_start_1 .. :try_end_1} :catchall_1

    :goto_2
    return-void

    :cond_1
    :try_start_2
    iget-object v2, p0, Lnbisdk/dg$b;->fb:Lnbisdk/dg;

    invoke-static {v2}, Lnbisdk/dg;->b(Lnbisdk/dg;)Ljava/io/ByteArrayOutputStream;

    move-result-object v2

    invoke-virtual {v2}, Ljava/lang/Object;->wait()V
    :try_end_2
    .catchall {:try_start_2 .. :try_end_2} :catchall_1
    .catch Ljava/lang/InterruptedException; {:try_start_2 .. :try_end_2} :catch_0

    goto :goto_1

    :catch_0
    move-exception v2

    goto :goto_1

    :cond_2
    :try_start_3
    iget-object v2, p0, Lnbisdk/dg$b;->fb:Lnbisdk/dg;

    invoke-static {v2}, Lnbisdk/dg;->b(Lnbisdk/dg;)Ljava/io/ByteArrayOutputStream;

    move-result-object v2

    invoke-virtual {v2}, Ljava/io/ByteArrayOutputStream;->toByteArray()[B

    move-result-object v2

    iget-object v3, p0, Lnbisdk/dg$b;->fb:Lnbisdk/dg;

    invoke-static {v3}, Lnbisdk/dg;->b(Lnbisdk/dg;)Ljava/io/ByteArrayOutputStream;

    move-result-object v3

    invoke-virtual {v3}, Ljava/io/ByteArrayOutputStream;->reset()V

    monitor-exit v1
    :try_end_3
    .catchall {:try_start_3 .. :try_end_3} :catchall_1

    :try_start_4
    array-length v1, v2
    :try_end_4
    .catchall {:try_start_4 .. :try_end_4} :catchall_0

    if-lez v1, :cond_0

    :try_start_5
    invoke-virtual {p1, v2}, Ljava/io/OutputStream;->write([B)V

    invoke-virtual {p1}, Ljava/io/OutputStream;->flush()V
    :try_end_5
    .catchall {:try_start_5 .. :try_end_5} :catchall_0
    .catch Ljava/io/IOException; {:try_start_5 .. :try_end_5} :catch_1

    goto :goto_0

    :catch_1
    move-exception v0

    :try_start_6
    iget-object v1, p0, Lnbisdk/dg$b;->fb:Lnbisdk/dg;

    new-instance v2, Lcom/navbuilder/nb/NBException;

    const/16 v3, 0x7d5

    invoke-direct {v2, v3, v0}, Lcom/navbuilder/nb/NBException;-><init>(ILjava/lang/Exception;)V

    invoke-virtual {v1, v2}, Lnbisdk/dg;->g(Lcom/navbuilder/nb/NBException;)V
    :try_end_6
    .catchall {:try_start_6 .. :try_end_6} :catchall_0

    goto :goto_2

    :catchall_0
    move-exception v0

    throw v0

    :catchall_1
    move-exception v0

    :try_start_7
    monitor-exit v1
    :try_end_7
    .catchall {:try_start_7 .. :try_end_7} :catchall_1

    :try_start_8
    throw v0
    :try_end_8
    .catchall {:try_start_8 .. :try_end_8} :catchall_0
.end method

.method private eM()Z
    .locals 9

    const-wide/high16 v7, 0x1000

    const/4 v6, 0x0

    const/4 v5, 0x1

    iget-object v0, p0, Lnbisdk/dg$b;->fb:Lnbisdk/dg;

    invoke-static {v0}, Lnbisdk/dg;->c(Lnbisdk/dg;)Lnbisdk/rj;

    move-result-object v0

    invoke-interface {v0}, Lnbisdk/rj;->kR()Lnbisdk/sl;

    move-result-object v0

    invoke-interface {v0}, Lnbisdk/sl;->getHostName()Ljava/lang/String;

    move-result-object v0

    :try_start_0
    sget-boolean v1, Lnbisdk/bk;->DEBUG:Z

    if-eqz v1, :cond_0

    new-instance v1, Ljava/lang/StringBuilder;

    invoke-direct {v1}, Ljava/lang/StringBuilder;-><init>()V

    const-string v2, "Open connection to: "

    invoke-virtual {v1, v2}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v1

    invoke-virtual {v1, v0}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v1

    invoke-virtual {v1}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;

    move-result-object v1

    const-wide/high16 v2, 0x1000

    const/16 v4, 0x8

    invoke-static {v1, v2, v3, v4}, Lnbisdk/pn;->a(Ljava/lang/String;JB)V

    :cond_0
    iget-object v1, p0, Lnbisdk/dg$b;->fb:Lnbisdk/dg;

    invoke-static {v1}, Lnbisdk/dg;->c(Lnbisdk/dg;)Lnbisdk/rj;

    move-result-object v1

    invoke-interface {v1}, Lnbisdk/rj;->cm()Lnbisdk/qv;

    move-result-object v1

    iget-object v2, p0, Lnbisdk/dg$b;->fb:Lnbisdk/dg;

    iget-object v3, p0, Lnbisdk/dg$b;->fb:Lnbisdk/dg;

    invoke-static {v3}, Lnbisdk/dg;->c(Lnbisdk/dg;)Lnbisdk/rj;

    move-result-object v3

    invoke-interface {v3}, Lnbisdk/rj;->kR()Lnbisdk/sl;

    move-result-object v3

    invoke-interface {v1, v3}, Lnbisdk/qv;->b(Lnbisdk/sl;)Lnbisdk/kg;

    move-result-object v1

    invoke-static {v2, v1}, Lnbisdk/dg;->a(Lnbisdk/dg;Lnbisdk/kg;)Lnbisdk/kg;
    :try_end_0
    .catch Ljava/io/IOException; {:try_start_0 .. :try_end_0} :catch_0
    .catch Ljava/lang/SecurityException; {:try_start_0 .. :try_end_0} :catch_1

    iget-object v0, p0, Lnbisdk/dg$b;->fb:Lnbisdk/dg;

    invoke-static {v0}, Lnbisdk/dg;->d(Lnbisdk/dg;)I

    move-result v0

    if-nez v0, :cond_1

    iget-object v0, p0, Lnbisdk/dg$b;->fb:Lnbisdk/dg;

    invoke-static {v0}, Lnbisdk/dg;->e(Lnbisdk/dg;)Lnbisdk/kg;

    move-result-object v0

    if-eqz v0, :cond_1

    iget-object v0, p0, Lnbisdk/dg$b;->fb:Lnbisdk/dg;

    invoke-static {v0, v5}, Lnbisdk/dg;->a(Lnbisdk/dg;I)I

    iget-object v0, p0, Lnbisdk/dg$b;->fb:Lnbisdk/dg;

    invoke-virtual {v0}, Lnbisdk/dg;->close()V

    move v0, v6

    :goto_0
    return v0

    :catch_0
    move-exception v1

    new-instance v2, Ljava/lang/StringBuilder;

    invoke-direct {v2}, Ljava/lang/StringBuilder;-><init>()V

    invoke-virtual {v1}, Ljava/io/IOException;->getMessage()Ljava/lang/String;

    move-result-object v3

    invoke-virtual {v2, v3}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v2

    const-string v3, "Connector.open("

    invoke-virtual {v2, v3}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v2

    invoke-virtual {v2, v0}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v0

    const-string v2, ", Connector.READ_WRITE, false)\n"

    invoke-virtual {v0, v2}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v0

    invoke-virtual {v0}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;

    move-result-object v0

    invoke-static {v0, v7, v8, v5}, Lnbisdk/pn;->a(Ljava/lang/String;JB)V

    iget-object v0, p0, Lnbisdk/dg$b;->fb:Lnbisdk/dg;

    new-instance v2, Lcom/navbuilder/nb/NBException;

    const/16 v3, 0x7d4

    invoke-direct {v2, v3, v1}, Lcom/navbuilder/nb/NBException;-><init>(ILjava/lang/Exception;)V

    invoke-virtual {v0, v2}, Lnbisdk/dg;->g(Lcom/navbuilder/nb/NBException;)V

    move v0, v6

    goto :goto_0

    :catch_1
    move-exception v1

    new-instance v2, Ljava/lang/StringBuilder;

    invoke-direct {v2}, Ljava/lang/StringBuilder;-><init>()V

    invoke-virtual {v1}, Ljava/lang/SecurityException;->getMessage()Ljava/lang/String;

    move-result-object v3

    invoke-virtual {v2, v3}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v2

    const-string v3, "Connector.open("

    invoke-virtual {v2, v3}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v2

    invoke-virtual {v2, v0}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v0

    const-string v2, ", Connector.READ_WRITE, false)\n"

    invoke-virtual {v0, v2}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v0

    invoke-virtual {v0}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;

    move-result-object v0

    invoke-static {v0, v7, v8, v5}, Lnbisdk/pn;->a(Ljava/lang/String;JB)V

    iget-object v0, p0, Lnbisdk/dg$b;->fb:Lnbisdk/dg;

    new-instance v2, Lcom/navbuilder/nb/NBException;

    const/16 v3, 0x18

    invoke-direct {v2, v3, v1}, Lcom/navbuilder/nb/NBException;-><init>(ILjava/lang/Exception;)V

    invoke-virtual {v0, v2}, Lnbisdk/dg;->g(Lcom/navbuilder/nb/NBException;)V

    move v0, v6

    goto :goto_0

    :cond_1
    iget-object v0, p0, Lnbisdk/dg$b;->fb:Lnbisdk/dg;

    invoke-static {v0}, Lnbisdk/dg;->d(Lnbisdk/dg;)I

    move-result v0

    if-eq v0, v5, :cond_2

    new-instance v0, Ljava/lang/IllegalStateException;

    const-string v1, "opened non-opening conn"

    invoke-direct {v0, v1}, Ljava/lang/IllegalStateException;-><init>(Ljava/lang/String;)V

    throw v0

    :cond_2
    iget-object v0, p0, Lnbisdk/dg$b;->fb:Lnbisdk/dg;

    const/4 v1, 0x2

    invoke-static {v0, v1}, Lnbisdk/dg;->a(Lnbisdk/dg;I)I

    sget-boolean v0, Lnbisdk/bk;->cG:Z

    if-eqz v0, :cond_3

    const-string v0, "open"

    const-string v1, "opensock"

    const-string v2, "Connection.java"

    const/16 v3, 0x129

    invoke-static {v0, v1, v2, v3}, Lnbisdk/ef;->a(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;I)V

    :cond_3
    move v0, v5

    goto/16 :goto_0
.end method

.method private eN()Ljava/io/OutputStream;
    .locals 5

    :try_start_0
    iget-object v0, p0, Lnbisdk/dg$b;->fb:Lnbisdk/dg;

    invoke-static {v0}, Lnbisdk/dg;->e(Lnbisdk/dg;)Lnbisdk/kg;

    move-result-object v0

    invoke-interface {v0}, Lnbisdk/kg;->w()Ljava/io/OutputStream;
    :try_end_0
    .catch Ljava/io/IOException; {:try_start_0 .. :try_end_0} :catch_0

    move-result-object v0

    :goto_0
    return-object v0

    :catch_0
    move-exception v0

    const-string v1, "sock.openOutputStream()\n"

    const-wide/high16 v2, 0x1000

    const/4 v4, 0x1

    invoke-static {v1, v2, v3, v4}, Lnbisdk/pn;->a(Ljava/lang/String;JB)V

    iget-object v1, p0, Lnbisdk/dg$b;->fb:Lnbisdk/dg;

    new-instance v2, Lcom/navbuilder/nb/NBException;

    const/16 v3, 0x7d5

    invoke-direct {v2, v3, v0}, Lcom/navbuilder/nb/NBException;-><init>(ILjava/lang/Exception;)V

    invoke-virtual {v1, v2}, Lnbisdk/dg;->g(Lcom/navbuilder/nb/NBException;)V

    const/4 v0, 0x0

    goto :goto_0
.end method


# virtual methods
.method public final cw()V
    .locals 5

    const/4 v4, 0x0

    sget-boolean v0, Lnbisdk/bk;->DEBUG:Z

    if-eqz v0, :cond_0

    iget-object v0, p0, Lnbisdk/dg$b;->fb:Lnbisdk/dg;

    invoke-static {v0}, Lnbisdk/dg;->a(Lnbisdk/dg;)Lnbisdk/ov;

    move-result-object v0

    const-string v1, "network output thread starting"

    invoke-virtual {v0, v1}, Lnbisdk/ov;->info(Ljava/lang/String;)V

    :cond_0
    :try_start_0
    invoke-direct {p0}, Lnbisdk/dg$b;->eM()Z

    move-result v0

    if-eqz v0, :cond_2

    new-instance v0, Lnbisdk/dg$a;

    iget-object v1, p0, Lnbisdk/dg$b;->fb:Lnbisdk/dg;

    invoke-direct {v0, v1}, Lnbisdk/dg$a;-><init>(Lnbisdk/dg;)V

    invoke-virtual {v0}, Lnbisdk/dg$a;->start()V

    invoke-direct {p0}, Lnbisdk/dg$b;->eN()Ljava/io/OutputStream;
    :try_end_0
    .catchall {:try_start_0 .. :try_end_0} :catchall_1
    .catch Ljava/lang/Exception; {:try_start_0 .. :try_end_0} :catch_0

    move-result-object v0

    if-eqz v0, :cond_1

    :try_start_1
    invoke-direct {p0, v0}, Lnbisdk/dg$b;->a(Ljava/io/OutputStream;)V
    :try_end_1
    .catchall {:try_start_1 .. :try_end_1} :catchall_0

    :cond_1
    :try_start_2
    invoke-virtual {v0}, Ljava/io/OutputStream;->close()V
    :try_end_2
    .catchall {:try_start_2 .. :try_end_2} :catchall_1
    .catch Ljava/io/IOException; {:try_start_2 .. :try_end_2} :catch_1
    .catch Ljava/lang/Exception; {:try_start_2 .. :try_end_2} :catch_0

    :cond_2
    :goto_0
    iget-object v0, p0, Lnbisdk/dg$b;->fb:Lnbisdk/dg;

    invoke-static {v0, v4}, Lnbisdk/dg;->a(Lnbisdk/dg;Ljava/lang/Exception;)V

    :goto_1
    sget-boolean v0, Lnbisdk/bk;->DEBUG:Z

    if-eqz v0, :cond_3

    iget-object v0, p0, Lnbisdk/dg$b;->fb:Lnbisdk/dg;

    invoke-static {v0}, Lnbisdk/dg;->a(Lnbisdk/dg;)Lnbisdk/ov;

    move-result-object v0

    const-string v1, "network output thread stopped"

    invoke-virtual {v0, v1}, Lnbisdk/ov;->info(Ljava/lang/String;)V

    :cond_3
    return-void

    :catchall_0
    move-exception v1

    :try_start_3
    invoke-virtual {v0}, Ljava/io/OutputStream;->close()V
    :try_end_3
    .catchall {:try_start_3 .. :try_end_3} :catchall_1
    .catch Ljava/io/IOException; {:try_start_3 .. :try_end_3} :catch_2
    .catch Ljava/lang/Exception; {:try_start_3 .. :try_end_3} :catch_0

    :goto_2
    :try_start_4
    throw v1
    :try_end_4
    .catchall {:try_start_4 .. :try_end_4} :catchall_1
    .catch Ljava/lang/Exception; {:try_start_4 .. :try_end_4} :catch_0

    :catch_0
    move-exception v0

    :try_start_5
    sget-boolean v1, Lnbisdk/bk;->cG:Z

    if-eqz v1, :cond_4

    new-instance v1, Ljava/lang/StringBuilder;

    invoke-direct {v1}, Ljava/lang/StringBuilder;-><init>()V

    const-string v2, "Exception caught : "

    invoke-virtual {v1, v2}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v1

    invoke-virtual {v0}, Ljava/lang/Exception;->getMessage()Ljava/lang/String;

    move-result-object v0

    invoke-virtual {v1, v0}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v0

    invoke-virtual {v0}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;

    move-result-object v0

    const-string v1, "OutputThread.runprotected()"

    const-string v2, "Connection.java"

    const/16 v3, 0xd6

    invoke-static {v0, v1, v2, v3}, Lnbisdk/ef;->a(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;I)V
    :try_end_5
    .catchall {:try_start_5 .. :try_end_5} :catchall_1

    :cond_4
    iget-object v0, p0, Lnbisdk/dg$b;->fb:Lnbisdk/dg;

    invoke-static {v0, v4}, Lnbisdk/dg;->a(Lnbisdk/dg;Ljava/lang/Exception;)V

    goto :goto_1

    :catchall_1
    move-exception v0

    iget-object v1, p0, Lnbisdk/dg$b;->fb:Lnbisdk/dg;

    invoke-static {v1, v4}, Lnbisdk/dg;->a(Lnbisdk/dg;Ljava/lang/Exception;)V

    throw v0

    :catch_1
    move-exception v0

    goto :goto_0

    :catch_2
    move-exception v0

    goto :goto_2
.end method

.method public final cx()Lcom/navbuilder/nb/c;
    .locals 1

    iget-object v0, p0, Lnbisdk/dg$b;->fb:Lnbisdk/dg;

    invoke-static {v0}, Lnbisdk/dg;->f(Lnbisdk/dg;)Lcom/navbuilder/nb/c;

    move-result-object v0

    return-object v0
.end method
